//
//  UIView+saveImage.m
//  TravelGuideMdd
//
//  Created by 陈曦 on 13-8-6.
//  Copyright (c) 2013年 mafengwo.com. All rights reserved.
//

#import "UIView+saveImage.h"
#import <QuartzCore/QuartzCore.h>

@implementation UIView(saveImage)

-(UIImage*)saveImage:(CGRect)aRect
{
    CGFloat scale = [UIScreen mainScreen].scale;
    UIGraphicsBeginImageContextWithOptions(aRect.size, YES, scale);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextTranslateCTM(context, -aRect.origin.x, -aRect.origin.y);

    [self.layer renderInContext:context];
    
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}

- (UIImage*)saveImage
{
    return  [self saveImage:self.bounds];
}

@end
